CHARTS
Photo by Adrien Taylor on Unsplash
I stopped (going to) school in order to marry..
— Nafissa, Niger
url_root <- "https://raw.githubusercontent.com/UN-AVT/kamino-source/main/sources/0-shared/data/"
url_file <- "child-marriage/child-marriage.csv"
url <- paste0(url_root, url_file)
df <- read.csv(url, header = TRUE, stringsAsFactors = TRUE)
# Remove second column
df = select(df,-2)
df
theme_opts <- theme(
axis.text.x = element_blank(),
axis.text.y = element_blank(),
axis.ticks = element_blank(),
text = element_text(family = "inconsolata", size = 14),
strip.text = element_text( size = 11, color = "white", hjust = 0.5 ),
strip.background = element_rect( fill = "black", color = NA, size = 1.5, linetype = "solid" ), # color = "deepskyblue4"
#plot.background = element_rect( fill = "black", color = NA ),
plot.title = element_text( color = "black", size = 20, face = "bold" ),
plot.subtitle = element_text( color = "black", size = 16 ),
plot.caption = element_text( color = "black", size = 14, hjust = 0.5, margin = margin( t=20,0,10,0 ) ),
panel.background = element_rect( fill = "black"), # requires theme_classic()
panel.spacing.x = unit( 0.1, "cm" ),
panel.spacing.y = unit( 0.1, "cm" ),
legend.position = "top",
legend.title = element_blank(),
legend.justification = "right",
legend.key.width = unit( 4.5, "cm"),
legend.text = element_text( margin = margin(0, 0, 0, -125) ),
legend.key = element_rect( colour = "black", size = 1, linetype = "solid" ),
legend.box.margin = margin( c(0,33,0,0) )
)
# Make the plot
v1 <- ggplot( df, aes( x = Pivot.Field.Names, y = Pivot.Field.Values, fill = Pivot.Field.Names ) ) +
geom_bar( stat = "identity", width = 0.75, alpha = 0.5 ) +
scale_fill_manual( values = c( "lightblue1", "mediumaquamarine", "sandybrown" ) ) +
facet_wrap( ~ Country, ncol = 8, labeller = label_wrap_gen()) +
labs( x = NULL, y = NULL,
title="Child Marriage",
subtitle="Percentage of underage females and males who get married across the world",
caption="Source: UNICEF global databses, 2020, based on DHS, MICS and other national surveys, 2013-2019") +
geom_text( aes( label = scales::percent(Pivot.Field.Values, accuracy = 0.1L), y = Pivot.Field.Values, color = Pivot.Field.Names ), vjust = -0.8, size = 3, family = "inconsolata" ) +
scale_color_manual( values = c( "lightblue1", "mediumaquamarine", "sandybrown" ) ) +
theme_classic() +
theme_opts
# Print the plot
girafe(ggobj = v1, width_svg = 16, height_svg = 30,
options = list(opts_sizing(rescale = TRUE, width = 1.0)))